import React from "react";
import { useRoutes, Navigate } from "react-router";
import BaseLayout from "./layouts/Base";
import Login from "@pages/Login";
import Notfound from "@components/NotFound";
import consoleRoutes from "@pages/console/route";
function usePages() {
  const pages = {
    path: "/",
    element: <BaseLayout />,
    children: [
      { path: "/login", element: <Login /> },
      {
        index: true,
        element: <Navigate to={"/login"} replace />,
      },
    ],
  };

  const routes = [
    pages,
    ...consoleRoutes,
    {
      path: "/404",
      element: <Notfound />,
    },
    {
      path: "*",
      element: <Navigate to={"/404"} replace />,
    },
  ];
  return routes;
}

export default function Pages() {
  const routes = usePages();
  return useRoutes(routes);
}
